package com.zlj.accountant.db.dao;

import java.util.List;
import java.util.UUID;

import com.zlj.accountant.core.HandlerManager;
import com.zlj.accountant.core.ann.Publish;
import com.zlj.accountant.db.entity.TCashAccount;

public class AccountCashInternalService extends MainService<TCashAccount> {

	public AccountCashInternalService(DBHelper db) {
		super(db);
	}
	
	@Publish
	protected final class GetTCashAccountProvider extends ResultProvider<TCashAccount>{

		@Override
        public TCashAccount provide(HandlerManager handler) throws Exception{
			List<TCashAccount> list = getDao().queryForAll();
			if(list.size()==0){
				TCashAccount e = new TCashAccount();
				e.setId(UUID.randomUUID());
				e.setName(TCashAccount.Name);
				createOrUpdate(e);
				return e;
			}else{
				return list.get(0);
			}
       }
		
	}

}
